package com.cpkso.yzx.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.cpkso.yzx.domain.User;
import com.cpkso.yzx.service.InternalService;

import runze.util.base.BaseAction;
import runze.util.base.Response;

@SuppressWarnings("serial")
@Controller
@Scope("prototype")
public class InternalAction extends BaseAction<Object> {
	public String modifyAccount() {
		internalService.modifyAccount(user);
		return SUCCESS;
	}
	
	public String login() {
		response = new Response();
		if (user == null) {
			response.failure("user null");
			return SUCCESS;
		}
		response = internalService.login(user);
		if (!response.getMsg().isSuccess()) {
			response.failure("user false");
			return SUCCESS;
		}
		
		Object data = response.getData();
		super.putSession("user", data);
		user.setPassword(null);
		
		return SUCCESS;
	}
	
	private User user;
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	private Response response;
	public Response getResponse() {
		return response;
	}

	@Autowired
	private InternalService internalService;
}
